﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
namespace Tools
{
    public class DBHelper
    {
        static string connStr = "Data Source=rm-bp13x228e5ip7ogsyzo.sqlserver.rds.aliyuncs.com,3433;Initial Catalog=Team_0101_BookShopDB;Persist Security Info=True;User ID=student;Password=abc123!@#";
        
        public static SqlDataReader ExecuteQuery(string str)
        {
            SqlConnection conn=new SqlConnection(connStr);
            SqlCommand cmd = new SqlCommand(str,conn);
            conn.Open();
            return cmd.ExecuteReader(CommandBehavior.CloseConnection);
        }

        public static void Execute(string str)
        {
            SqlConnection conn = new SqlConnection(connStr);
            SqlCommand cmd = new SqlCommand(str, conn);
            conn.Open();
            cmd.ExecuteNonQuery();
            conn.Close();
        }
    }
}
